<?php
$this->breadcrumbs=array(
	Yii::t('base','Routings')=>array('admin'),
	Yii::t('base','Manage'),
);
Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
	$('.search-form').toggle();
	return false;
});
$('.search-form form').submit(function(){
	$.fn.yiiGridView.update('routing-grid', {
		data: $(this).serialize()
	});
	return false;
});
");
$ispublic = yii::app()->request->getParam(ispublic);
$level=yii::app()->user->level();
?>

<h1><?php echo Yii::t('base','Manage Routings');?></h1>

<?php echo Yii::t('base','<p>
You may optionally enter a comparison operator (<b>&lt;</b>, <b>&lt;=</b>, <b>&gt;</b>, <b>&gt;=</b>, <b>&lt;&gt;</b>
or <b>=</b>) at the beginning of each of your search values to specify how the comparison should be done.
</p>');?>

<?php echo CHtml::link(Yii::t('base','Advanced Search'),'#',array('class'=>'search-button')); ?>
<div class="search-form" style="display:none">
<?php $this->renderPartial('_search',array(
	'model'=>$model,
)); ?>
</div><!-- search-form -->
<?php if(yii::app()->user->level==1){?>
<a class="btn btn-small create" title="<?php echo Yii::t('base','Create Routing')?>" href="<?php echo Yii::app()->request->baseUrl; ?>/routing/create"><?php echo Yii::t('base','Create Routing')?></a>
<?php }elseif(yii::app()->request->getParam("ispublic")==0){?>
<a class="btn btn-small create" title="<?php echo Yii::t('base','Create Routing')?>" href="<?php echo Yii::app()->request->baseUrl; ?>/routing/create"><?php echo Yii::t('base','Create Routing')?></a>
<?php }?>
<?php $this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'routing-grid',
	'dataProvider'=>$model->search(),
	//'filter'=>$model,
	'itemsCssClass'=>'responsive table table-striped table-bordered',
	'pager'=>array('class'=>'CLinkPager','hiddenPageCssClass'=>'','firstPageCssClass'=>'first paginate_button','htmlOptions'=>array('class'=>'dataTables_paginate paging_full_numbers"'),'header'=>""),
	'pagerCssClass'=>'pagination',
	'cssFile'=>false,
	'template'=>'{items}{summary}{pager}',
	'columns'=>array(
	//	'routing_id',
	//	array('name'=>'user_id','value'=>'Routing::model()->getUserName($data->routing_id)'),
		'IP',
	//	'maskbit',
		array('name'=>'tag','value'=>'Routing::model()->getTagName($data->routing_id)'),
                array('name'=>'vpnid','header'=>Yii::t('base','Server'),'value'=>'Vpnlist::model()->find("id=".$data->vpnid)->comment'),
	//	'Ispublic',
                'remark',
		array(
		'class'=>'CButtonColumn',
		'header'=>Yii::t('base','Operate'),
		'updateButtonImageUrl'=>array('class'=>'gicon-edit'),
		'updateButtonOptions'=>array('class'=>'btn btn-small'),
		'deleteButtonImageUrl'=>array('class'=>'gicon-edit'),
		'updateButtonUrl'=>'Yii::app()->createUrl("routing/update",array("id"=>$data->routing_id))',
		'deleteButtonUrl'=>'Yii::app()->createUrl("routing/delete",array("id"=>$data->routing_id))',
		'deleteButtonOptions'=>array('class'=>'btn btn-inverse btn-small'),
		'template'=>'{delete}{update}',
		'headerHtmlOptions'=>array('style'=>'width:30%'),
		'visible'=>(($ispublic==1 && $level==1) || ($ispublic==0 && $level!=1) ||($ispublic=="")),
),
	),
)); ?>
